package controllers

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"pets.ser163.cn/model"
	"pets.ser163.cn/services"
)

// @Summary 获取用户列表
// @Description 获取所有用户列表
// @Produce  json
// @Success 200 {array} model.Users
// @Router /api/users [get]
func GetUsers(c *gin.Context) {
	users, err := services.GetAllUsers()
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}
	c.JSON(http.StatusOK, users)
}

// CreateUser 创建新用户
func CreateUser(c *gin.Context) {
	var user model.Users
	if err := c.ShouldBindJSON(&user); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	if err := services.CreateUser(&user); err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
		return
	}
	c.JSON(http.StatusOK, user)
}

// Login 用户登录
func Login(c *gin.Context) {
	// 登录逻辑
	c.JSON(http.StatusOK, gin.H{"message": "login successful"})
}

// Register 用户注册
func Register(c *gin.Context) {
	// 注册逻辑
	c.JSON(http.StatusOK, gin.H{"message": "register successful"})
}
